import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'package:top_foundation/component/tag.dart';
import 'package:top_foundation/top_foundation.dart';
import 'package:whale/helper/utils/color.dart';
import 'package:whale/helper/utils/img_util.dart';
import 'package:whale/pages/home/main/logic.dart';

import '../../../../helper/route/routes.dart';
import '../../../../helper/utils/MyUnderlineTabIndicator.dart';
import '../../../app_tab/controller.dart';

class MarketQuickReview extends GetView<HomeLogic> {
  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        Container(
          key: controller.state.keyGreen2,
          padding: EdgeInsets.all(15.r),
          height: 55.r,
          child: Row(
            children: [
              Text(
                '精选观市报告',
                style: TextStyle(
                    color: ColorsUtil.title,
                    fontSize: 16.r,
                    fontWeight: FontWeight.bold),
              ),
              Spacer(),
              InkWell(
                onTap: () {
                  final ctrl = Get.find<AppTabController>();
                  ctrl.clickTab(2);
                },
                child: Text(
                  '查看更多',
                  style: TextStyle(color: ColorsUtil.subTitle, fontSize: 12.r),
                ),
              ),
              SizedBox(
                width: 5.r,
              ),
              Image.asset(
                'icon_right.png'.imgPathMe,
                width: 4.5.r,
                height: 8.r,
              )
            ],
          ),
        ),
        Container(
          margin: EdgeInsets.symmetric(horizontal: 15.r),
          color: Colors.white,
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              TabBar(
                controller: controller.state.report_tabCtrl,
                isScrollable: true,
                indicatorColor: ColorsUtil.title,
                unselectedLabelColor: ColorsUtil.subTitle,
                labelColor: ColorsUtil.title,
                labelStyle:
                    TextStyle(fontSize: 14.r, fontWeight: FontWeight.w600),
                unselectedLabelStyle: TextStyle(fontSize: 14.r),
                indicator: MyUnderlineTabIndicator(
                    borderSide:
                        const BorderSide(width: 3, color: ColorsUtil.title)),
                onTap: (int index) =>
                    controller.getPageDoc(type: index == 0 ? '政策措施' : '招标采购'),
                tabs: controller.state.reportTabTitles
                    .map((e) => Tab(text: e))
                    .toList(),
              ),
              Container(
                height: 0.5.r,
                color: Color(0xffF4F4F5),
                margin: EdgeInsets.symmetric(vertical: 4.r),
              ),
              ListView.separated(
                itemBuilder: (context, index) {
                  return Container(
                      child: InkWell(
                    onTap: () {
                      Get.toNamed(RouterPath.means_detail,
                          arguments: controller.state.docjx[index]);
                    },
                    child: Container(
                      color: Colors.white,
                      padding: EdgeInsets.symmetric(
                          horizontal: 15.r, vertical: 11.r),
                      child: Column(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        children: [
                          Text(
                            controller.state.docjx[index].documentTitle ?? '',
                            style: TextStyle(
                              color: ColorsUtil.title,
                              fontSize: 14.r,
                              fontWeight: FontWeight.w500,
                            ),
                            maxLines: 2,
                            overflow: TextOverflow.ellipsis,
                          ),
                          SizedBox(
                            height: 10.r,
                          ),
                          Text(
                            controller.state.docjx[index].createTime
                                    ?.substring(0, 10) ??
                                '',
                            style: TextStyle(
                                color: ColorsUtil.content, fontSize: 10.sp),
                          )
                        ],
                      ),
                    ),
                  ));
                },
                padding: EdgeInsets.zero,
                itemCount: controller.state.docjx.length,
                shrinkWrap: true,
                physics: const NeverScrollableScrollPhysics(),
                separatorBuilder: (BuildContext context, int index) =>
                    Container(
                  height: 0.5.r,
                  color: Color(0xffF4F4F5),
                  margin: EdgeInsets.symmetric(horizontal: 15.r),
                ),
              ),
            ],
          ),
        ),
        SizedBox(
          height: 15.r,
        ),
        Row(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          children: [
            Container(
              width: 165.r,
              height: 188.r,
              decoration: BoxDecoration(
                  borderRadius: BorderRadius.circular(4.r),
                  image: DecorationImage(
                      image: AssetImage('bg_home1.png'.imgPathHome),
                      fit: BoxFit.fill)),
              padding: EdgeInsets.fromLTRB(15.r, 18.r, 0, 12.r),
              margin: EdgeInsets.only(
                left: 15.r,
              ),
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Row(
                    crossAxisAlignment: CrossAxisAlignment.end,
                    children: [
                      Text(
                        '政策措施',
                        style: TextStyle(
                            color: Colors.white,
                            fontSize: 14.r,
                            fontWeight: FontWeight.bold),
                      ),
                      Spacer(),
                      Text(
                        '（篇）',
                        style: TextStyle(color: Colors.white, fontSize: 10.r),
                      ),
                      SizedBox(
                        width: 10.r,
                      ),
                    ],
                  ),
                  SizedBox(
                    height: 8.r,
                  ),
                  Text(
                    '6,018',
                    style: TextStyle(
                        color: Colors.white,
                        fontSize: 30.r,
                        fontWeight: FontWeight.bold),
                  ),
                  Container(
                    width: 1.sw,
                    height: 0.5.r,
                    margin: EdgeInsets.only(top: 10.r, bottom: 10.r),
                    color: Colors.white,
                  ),
                  Row(
                    children: [
                      Text(
                        '高风险',
                        style: TextStyle(color: Colors.white, fontSize: 12.r),
                      ),
                      Spacer(),
                      Text(
                        '400',
                        style: TextStyle(
                            color: Colors.white,
                            fontSize: 12.r,
                            fontWeight: FontWeight.w500),
                      ),
                      SizedBox(
                        width: 15.r,
                      ),
                    ],
                  ),
                  SizedBox(
                    height: 10.r,
                  ),
                  Row(
                    children: [
                      Text(
                        '中风险',
                        style: TextStyle(color: Colors.white, fontSize: 12.r),
                      ),
                      Spacer(),
                      Text(
                        '400',
                        style: TextStyle(
                            color: Colors.white,
                            fontSize: 12.r,
                            fontWeight: FontWeight.w500),
                      ),
                      SizedBox(
                        width: 15.r,
                      ),
                    ],
                  ),
                  SizedBox(
                    height: 10.r,
                  ),
                  Row(
                    children: [
                      Text(
                        '低风险',
                        style: TextStyle(color: Colors.white, fontSize: 12.r),
                      ),
                      Spacer(),
                      Text(
                        '400',
                        style: TextStyle(
                            color: Colors.white,
                            fontSize: 12.r,
                            fontWeight: FontWeight.w500),
                      ),
                      SizedBox(
                        width: 15.r,
                      ),
                    ],
                  ),
                ],
              ),
            ),
            Container(
              width: 165.r,
              height: 188.r,
              decoration: BoxDecoration(
                  borderRadius: BorderRadius.circular(4.r),
                  image: DecorationImage(
                      image: AssetImage('bg_home2.png'.imgPathHome),
                      fit: BoxFit.fill)),
              padding: EdgeInsets.fromLTRB(15.r, 18.r, 0, 12.r),
              margin: EdgeInsets.only(right: 15.r),
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Row(
                    crossAxisAlignment: CrossAxisAlignment.end,
                    children: [
                      Text(
                        '招标采购',
                        style: TextStyle(
                            color: Colors.white,
                            fontSize: 14.r,
                            fontWeight: FontWeight.bold),
                      ),
                      Spacer(),
                      Text(
                        '（篇）',
                        style: TextStyle(color: Colors.white, fontSize: 10.r),
                      ),
                      SizedBox(
                        width: 10.r,
                      ),
                    ],
                  ),
                  SizedBox(
                    height: 8.r,
                  ),
                  Text(
                    '32,018',
                    style: TextStyle(
                        color: Colors.white,
                        fontSize: 30.r,
                        fontWeight: FontWeight.bold),
                  ),
                  Container(
                    width: 1.sw,
                    height: 0.5.r,
                    margin: EdgeInsets.only(top: 10.r, bottom: 10.r),
                    color: Colors.white,
                  ),
                  Row(
                    children: [
                      Text(
                        '高风险',
                        style: TextStyle(color: Colors.white, fontSize: 12.r),
                      ),
                      Spacer(),
                      Text(
                        '400',
                        style: TextStyle(
                            color: Colors.white,
                            fontSize: 12.r,
                            fontWeight: FontWeight.w500),
                      ),
                      SizedBox(
                        width: 15.r,
                      ),
                    ],
                  ),
                  SizedBox(
                    height: 10.r,
                  ),
                  Row(
                    children: [
                      Text(
                        '中风险',
                        style: TextStyle(color: Colors.white, fontSize: 12.r),
                      ),
                      Spacer(),
                      Text(
                        '400',
                        style: TextStyle(
                            color: Colors.white,
                            fontSize: 12.r,
                            fontWeight: FontWeight.w500),
                      ),
                      SizedBox(
                        width: 15.r,
                      ),
                    ],
                  ),
                  SizedBox(
                    height: 10.r,
                  ),
                  Row(
                    children: [
                      Text(
                        '低风险',
                        style: TextStyle(color: Colors.white, fontSize: 12.r),
                      ),
                      Spacer(),
                      Text(
                        '400',
                        style: TextStyle(
                            color: Colors.white,
                            fontSize: 12.r,
                            fontWeight: FontWeight.w500),
                      ),
                      SizedBox(
                        width: 15.r,
                      ),
                    ],
                  ),
                ],
              ),
            ),
          ],
        )
      ],
    );
  }
}
